home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / Multi-Panel Dialogs 1.1 / MPDTest App / Panels / CCommunicationPanel.cp next >
Encoding:
Text File  |  1996-09-26  |  4.4 KB  |  142 lines  |  [TEXT/R*ch]

  1. /*
  2.     File:            CCommunicationPanel.cp
  3.  
  4.     Contains:    Class stub to use as a template for creating your own multi-pane
  5.                     dialog panels.
  6.  
  7.     Written by:    Mike Shields
  8.  
  9.     Copyright:    Copyright © 1996 Mike Shields.  All Rights Reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.                 02/01/96    MSS        New
  14.     To Do:
  15. */
  16. #include "CCommunicationPanel.h"
  17.  
  18. #include <LStream.h>
  19. #include <LControl.h>
  20. #include <LEditField.h>
  21.  
  22. #ifndef __Dialogs__
  23. #include <Dialogs.h>
  24. #endif
  25.  
  26. #pragma options align=mac68k
  27. struct SCommPanelRec
  28. {
  29.     Int16        encrypt;
  30.     Int16        universalTrans;
  31.     Int16        commMode;
  32.     Int32        commFreq;
  33. };
  34. #pragma options align=reset
  35.  
  36. typedef struct SCommPanelRec    CommPanelDataRec, *CommPanelDataPtr, **CommPanelDataHandle;
  37.  
  38. //---------------------------------------------------------------------------
  39. // CCommunicationPanel::CreateFromStream
  40. //---------------------------------------------------------------------------
  41. CCommunicationPanel* CCommunicationPanel::CreateFromStream(LStream* inStream)
  42. {
  43.     return (new CCommunicationPanel(inStream));
  44. }
  45.  
  46. //---------------------------------------------------------------------------
  47. // CCommunicationPanel::CCommunicationPanel
  48. //---------------------------------------------------------------------------
  49. CCommunicationPanel::CCommunicationPanel()
  50. {
  51. }
  52.  
  53. //---------------------------------------------------------------------------
  54. // CCommunicationPanel::CCommunicationPanel
  55. //---------------------------------------------------------------------------
  56. CCommunicationPanel::CCommunicationPanel(const CCommunicationPanel &inOriginal) 
  57.     : CMPDPanel(inOriginal) 
  58. {
  59. }
  60.  
  61. //---------------------------------------------------------------------------
  62. // CCommunicationPanel::CCommunicationPanel
  63. //---------------------------------------------------------------------------
  64. CCommunicationPanel::CCommunicationPanel(const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo) 
  65.     : CMPDPanel(inPaneInfo, inViewInfo) 
  66. {
  67. }
  68.  
  69. //---------------------------------------------------------------------------
  70. // CCommunicationPanel::CCommunicationPanel
  71. //---------------------------------------------------------------------------
  72. CCommunicationPanel::CCommunicationPanel(LStream *inStream) 
  73.     : CMPDPanel(inStream)
  74. {
  75. }
  76.  
  77. //---------------------------------------------------------------------------
  78. // CCommunicationPanel::CCommunicationPanel
  79. //---------------------------------------------------------------------------
  80. CCommunicationPanel::~CCommunicationPanel()
  81. {
  82. }
  83.     
  84. //---------------------------------------------------------------------------
  85. // CCommunicationPanel::GetData
  86. //---------------------------------------------------------------------------
  87. void CCommunicationPanel::GetData(Handle inDataToReplace)
  88. {
  89.     LControl        *aControl;
  90.     LEditField    *aField;
  91.     CommPanelDataRec    newPrefs;
  92.     
  93.     aControl = (LControl*)this->FindPaneByID('Encr');
  94.     newPrefs.encrypt = aControl->GetValue();
  95.     aControl = (LControl*)this->FindPaneByID('Univ');
  96.     newPrefs.universalTrans = aControl->GetValue();
  97.     aControl = (LControl*)this->FindPaneByID('Mode');
  98.     newPrefs.commMode = aControl->GetValue();
  99.     aField = (LEditField*)this->FindPaneByID('Freq');
  100.     newPrefs.commFreq = aField->GetValue();    
  101.  
  102.     OSErr anErr = ::PtrToXHand(&newPrefs, inDataToReplace, sizeof(newPrefs));
  103.     ThrowIfOSErr_(anErr);
  104. }
  105.  
  106. //---------------------------------------------------------------------------
  107. // CCommunicationPanel::SetData
  108. //---------------------------------------------------------------------------
  109. void CCommunicationPanel::SetData(Handle inData)
  110. {
  111.     LControl        *aControl;
  112.     LEditField    *aField;
  113.     CommPanelDataHandle    newPrefs = (CommPanelDataHandle)inData;
  114.     
  115.     aControl = (LControl*)this->FindPaneByID('Encr');
  116.     aControl->SetValue((**newPrefs).encrypt);
  117.     aControl = (LControl*)this->FindPaneByID('Univ');
  118.     aControl->SetValue((**newPrefs).universalTrans);
  119.     aControl = (LControl*)this->FindPaneByID('Mode');
  120.     aControl->SetValue((**newPrefs).commMode);
  121.     aField = (LEditField*)this->FindPaneByID('Freq');
  122.     aField->SetValue((**newPrefs).commFreq);    
  123. }
  124.  
  125. //---------------------------------------------------------------------------
  126. // CCommunicationPanel::ValidatePanel
  127. //---------------------------------------------------------------------------
  128. Boolean CCommunicationPanel::ValidatePanel()
  129. {
  130.     LEditField    *aField;
  131.     aField = (LEditField*)this->FindPaneByID('Freq');
  132.     if ( aField->GetValue() > 100 )
  133.     {
  134.         ::Alert(200, NULL);
  135.         aField->SelectAll();
  136.         LCommander::SwitchTarget(aField);
  137.         return false;
  138.     }
  139.     return true;
  140. }
  141.  
  142.